package com.itcast.demo.test;

import java.util.Stack;

/**
 * @author eternity
 */
public class Main {
    public static void main(String[] args) {
        int num = func1("quackquack");
        System.out.println(num);
    }

    public static int func1(String str) {
        if (str == null) {
            return -1;
        }
        Stack<Character> stack = new Stack<>();
        for (int i = 0;i < str.length();i ++) {
            char c = str.charAt(i);
            if (stack.empty() && c == 'q') {
                stack.push(c);
            }
            if (stack.peek() == 'q' && c == 'u') {
                stack.pop();
            }
            if (stack.peek() == 'u' && c == 'a') {
                stack.push(c);
            }
            if (stack.peek() == 'a' && c == 'c') {
                stack.push(c);
            }
            if (stack.peek() == 'c' && c == 'k') {
                stack.push(c);
            }
        }
        
        return -1;
    }
}
